#include "help.hpp"
using namespace std;

class Solution
{
public:
    vector<int> v;
    void dfs(TreeNode *root)
    {
        if (root)
        {
            dfs(root->left);
            v.push_back(root->val);
            dfs(root->right);
        }
    }
    int kthSmallest(TreeNode *root, int k)
    {
        // 平衡二叉树的从小到大遍历
        dfs(root);
        return v[k - 1];
    }
};
int main(int argc, char const *argv[])
{
    printf("\033[31m--------华丽的分割线--------\n\n\n\033[0m");

    Solution s;

    auto root = create_tree("[5,3,6,2,4,null,null,1]");
    TreePrint t;
    t.print_tree_to_stdout(root);
    auto ve = s.kthSmallest(root, 3);
    cout << ve;
    cout << "\n";

    printf("\033[31m--------华丽的分割线--------\033[0m");
    return 0;
}
